package section8;

class person8_1{
    private String name;
    private int age;
    public person8_1(){
        System.out.println("调用了个人类的构造方法person()");
    }
    public void setNameAge(String name,int age){
        this.name=name;
        this.age=age;
    }
    public void show(){
        System.out.println("姓名:"+name+" 年龄："+age);
    }
}
class student8_1 extends person8_1{
    private String department;
    public student8_1(){
        //这里默认调用父类的无参构造方法
        //super();
        System.out.println("调用学生类的构造方法student()");
    }
    public void setDepartment(String department) {
        this.department = department;
        System.out.println("我是"+department+"的学生！");
    }
}
public class App8_1 {
    public static void main(String[] args) {
        student8_1 stu=new student8_1();
        stu.setNameAge("张文省",21);
        stu.show();
        stu.setDepartment("计算机系");
    }
}
